
clear all
set more off

use "data/raw/deport-persuasion-deidentified", clear 

drop if !inlist(treatment, "video", "control")

keep if attention=="Extremely interested,Not at all interested"
drop attention

* Generate outcome and treatment variables
drop if missing(deport_illegal)
gen deport = -2
replace deport = 2 if deport_illegal == "Strongly agree"
replace deport = 1 if deport_illegal == "Agree"
replace deport = 0 if deport_illegal == "Neither agree nor disagree"
replace deport = -1 if deport_illegal == "Disagree"
label var deport "The US should immediately deport all illegal Mexican immigrants."

drop if missing(posterior)
rename posterior post 
gen posterior = 2 if post == "Strongly agree"
replace posterior = 1 if post == "Agree"
replace posterior = 0 if post == "Neither agree nor disagree"
replace posterior = -1 if post == "Disagree"
replace posterior = -2 if post == "Strongly disagree"
drop post 
label var posterior "Illegal immigrants are more likely to commit serious crimes than US citizens."

gen info = treatment=="video"
lab var info "Information condition"
gen noinfo = treatment=="control"
lab var noinfo "Control condition"
drop treatment

* Generate demographic and control variables
gen ind = pol=="Independent"
lab var ind "Independent"
drop pol

gen partisan = .
replace partisan = 2 if liberal == "Very conservative"
replace partisan = 1 if liberal == "Conservative"
replace partisan = 0 if liberal == "Neither liberal nor conservative"
replace partisan = -1 if liberal == "Liberal"
replace partisan = -2 if liberal == "Very liberal"
label var partisan "Partisan leaning"

destring age, replace
label var age "Age"
gen age2 = age^2
lab var age2 "Age squared"
gen hisp = hispanic=="Yes"
lab var hisp "Spanish, Hispanic, or Latino"
drop hispanic
rename male sex
gen male = sex == "Male"
lab var male "Male"
drop sex

lab var educ "Education level"
rename educ education

gen white = race=="Caucasian/White"
lab var white "White"
lab var race "Race"


keep deport posterior info education race ind partisan age age2 hisp male white 

save "data/working/deport-persuasion.dta", replace
exit,clear
